package conf

import (
	"github.com/go-ini/ini"
	"github.com/sirupsen/logrus"
)

type Config struct {
	KafkaConfig `ini:"kafka"`
	EtcdConfig  `ini:"etcd"`
}

func NewConfig() *Config {
	return &Config{}
}

type KafkaConfig struct {
	Address  string `ini:"address"`
	ChanSize int64  `ini:"chan_size"`
}

type EtcdConfig struct {
	Address    string `ini:"address"`
	CollectKey string `ini:"collect_key"`
}

func (conf *Config) CreateConf() *Config {
	//1. 读取配置文件
	err := ini.MapTo(conf, "./conf/config.ini")
	if err != nil {
		logrus.Error("load config failed,err:%v\n", err)
		return nil
	}
	return conf
}
